package com.tianji.remark.task;

import com.tianji.remark.service.ILikedRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author Xinxuan Zhuo
 * @version 2024/3/4
 * <p>
 *
 * </p>
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class LikedTimesCheckTask {

    // 业务类型
    private final ForLikedTimesCheckTaskBizType bizTypes;


    // 单次任务最大处理量
    private static final int MAX_BIZ_SIZE = 30;

    // 记录表（点赞）
    private final ILikedRecordService recordService;

    /**
     * 20s执行一次点赞总数变更任务
     */
    @Scheduled(fixedDelay = 20000)
    public void checkLikedTimes() {
        String bizType = bizTypes.next();
        log.info("当前点赞总数变更任务定时任务所指定的业务类型是：{}", bizType);
        recordService.readLikedTimesAndSendMessage(bizType, MAX_BIZ_SIZE);
    }

}
